@extends('base.base')
@section('base')
    <!-- 内容区域 -->
    <div class="main-panel">
        <div class="content-wrapper">
            <div class="row">
                <div class="col-12 grid-margin stretch-card">
                    <div class="card">
                        <div class="card-body">
                            <h4 class="card-title">请修改白名单信息</h4>
                            <form class="forms-sample" id="form">

                                <div class="form-group">
                                    <label>渠道</label>
                                    <select class="form-control" id="channel_id" name="channel_id">
                                        <option value="">全部</option>
                                        @foreach($channelRes as $i)
                                            <option value="{{$i->id}}" @if($white->channel_id==$i->id) selected @endif>{{$i->name}}</option>
                                        @endforeach
                                    </select>
                                </div>

{{--                                <div class="form-group">--}}
{{--                                    <label>* 键 </label>--}}
{{--                                    <input type="text"  class="form-control required" name="item_key" placeholder="键" value="{{ $white->item_key }}">--}}
{{--                                </div>--}}
                                <div class="form-group">
                                    <label>* 域名或包名</label>
                                    <input type="text"  class="form-control required" name="item_value" placeholder="值" value="{{ $white->item_value }}">
                                </div>
                                <button type="button" onclick="commit({{ $white->id }})" class="btn btn-sm btn-gradient-primary btn-icon-text">
                                    <i class="mdi mdi-file-check btn-icon-prepend"></i>
                                    提交
                                </button>
                                <button type="button" onclick="cancel()" class="btn btn-sm btn-gradient-warning btn-icon-text">
                                    <i class="mdi mdi-reload btn-icon-prepend"></i>
                                    取消
                                </button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        function commit(id){
            if(!checkForm()){
                return false;
            }
            var data = $("#form").serializeObject();
            myRequest("/admin/whitelist/update/"+id,"post",data,function(res){
                layer.msg(res.msg)
                setTimeout(function(){
                    parent.location.reload();
                },1500)
            });
        }
        function cancel() {
            parent.location.reload();
        }
    </script>
@endsection
